﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace LanDBom.Models.Procure
{
    public class Find_INF_with_App_bian
    {
        LDbaseEntities LD = new LDbaseEntities();
        public List<Informa> find_lnf(string APP_bian)
        {
            List<Informa> listinfoemas = LD.Informa.Where(x => x.Inf_shen == APP_bian).ToList();
            //listinfoemas = listinfoemas.GroupBy(d => new { d.Inf_wu,d.Inf_gong }).Select(a => a.OrderByDescending(b => b.INF_qi).ElementAt(0)).ToList();
            return listinfoemas;
        }
        public List<Informa> find_lnf2(string APP_bian)
        {
            List<Informa> listinfoemas = LD.Informa.Where(x => x.Inf_shen == APP_bian).ToList();
            listinfoemas = listinfoemas.GroupBy(d => new { d.BOM2_id, d.Inf_gong }).Select(a => a.OrderByDescending(b => b.INF_qi).ElementAt(0)).ToList();
            return listinfoemas;
        }

        public List<Informa> find_lnf_witn_zhuang(string APP_bian)
        {
            List<Informa> listinfoemas = LD.Informa.Where(x => x.Inf_shen == APP_bian && (x.Inf_zhuang == "已提交" || x.Inf_zhuang == "已确认")).ToList();
            List<Informa> listinfoemas2 = listinfoemas.GroupBy(d => new { d.Inf_wu}).Select(a => a.OrderByDescending(b => b.INF_qi).ElementAt(0)).ToList();
            return listinfoemas2;
        }
        public List<Informa> find_lnf_witn_zhuang2(string APP_bian)
        {
            List<Informa> listinfoemas = LD.Informa.Where(x => x.Inf_shen == APP_bian && x.Inf_zhuang == "已确认").ToList();
            List<Informa> listinfoemas2 = listinfoemas.GroupBy(d => new { d.Inf_wu }).Select(a => a.OrderByDescending(b => b.INF_qi).ElementAt(0)).ToList();
            return listinfoemas2;
        }

        public List<Informa> find_lnf_witn_zhuang()
        {
            List<Informa> listinfoemas = LD.Informa.Where(x => x.Inf_shen == "物料询价" && x.Inf_zhuang == "等待中").ToList();
            listinfoemas= listinfoemas.GroupBy(d => new { d.Inf_wu }).Select(a => a.OrderBy(b => b.Inf_huiP).ElementAt(0)).ToList();
            return listinfoemas;
        }

        public List<Informa> find_lnf_witn_zhuang2()
        {
            List<Informa> listinfoemas = LD.Informa.Where(x => x.Inf_shen == "物料询价" && (x.Inf_zhuang == "已提交" || x.Inf_zhuang == "已确认")).ToList();
            listinfoemas = listinfoemas.GroupBy(d => new { d.Inf_wu }).Select(a => a.OrderBy(b => b.Inf_huiP).ElementAt(0)).ToList();
            return listinfoemas;
        }

        public List<Informa> find_lnf_witn_zhuang3()
        {
            List<Informa> listinfoemas = LD.Informa.Where(x => x.Inf_shen == "物料询价" && x.Inf_zhuang == "已确认").ToList();
            listinfoemas = listinfoemas.GroupBy(d => new { d.Inf_wu }).Select(a => a.OrderBy(b => b.Inf_huiP).ElementAt(0)).ToList();
            return listinfoemas;
        }
    }
}